<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="h" uri="http://cn.gson.com/jsp/mytag" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<!-- <link rel="stylesheet" href="static/easyui/themes/ui-pepper-grinder/easyui.css"/> -->
<link rel="stylesheet" href="static/easyui/themes/bootstrap/easyui.css"/>
<link rel="stylesheet" href="static/easyui/themes/icon.css"/>
<!-- 排班 -->

<!-- 住院中的登记界面css -->
<link rel="stylesheet" type="text/css" href="static/css/inhospital.css"/>
<!-- 住院通知界面的css -->
<link rel="stylesheet" type="text/css" href="static/css/inhospital-inform.css">
<!-- 住院护士站界面的css -->
<link rel="stylesheet" type="text/css" href="static/css/in-nursestand.css">
<!-- 住院医生站界面的css -->
<link rel="stylesheet" type="text/css" href="static/css/in-doctorstand.css">
<!-- 医疗卡管理界面css -->
<link rel="stylesheet"  type="text/css"  href="static/css/out-medicalcard.css"/>
<!--挂号界面css -->
<link rel="stylesheet"  type="text/css"  href="static/css/out-registrationoffice.css"/>
<!--医生看诊界面css -->
<link rel="stylesheet"  type="text/css" href="static/css/out-lookdoctor.css"/>
<!-- 主页界面css -->
<link rel="stylesheet"  type="text/css" href="static/css/outpatientregister.css"/>
<!-- 用户详情css -->
<link rel="stylesheet"  type="text/css" href="static/css/User.css"/>
<!--收费界面css -->
<link rel="stylesheet" href="static/css/out-chargemanagement.css"/>
<!--主页工作台界面css -->
<link rel="stylesheet" href="static/css/out-hospitalmain.css"/>
<!-- 门诊护士工作站css -->
<link rel="stylesheet" href="static/css/out-nurse.css"/>
<!-- 体检预约css -->
<link rel="stylesheet" href="static/css/checkupexamination.css"/>
<title>主页</title>
</head>
<style type="text/css">
 #arrange-tab td{background-color:none;text-align:center}
 
/*  .datagrid-header {
    position: absolute; visibility: hidden;
}  */

</style>
<body>
<script type="text/javascript">
$(function(){
	//点击折叠的里面按钮动态创建选项卡
	$(".fun").click(function(){
		//获取按钮内容
		var t=$(this).text();
		//路径
		var h=$(this).attr("data-href");
		var funId = $(this).attr("data-id");
		//有着按钮就打开
		if($("#tt").tabs("exists",t)){
			$("#tt").tabs("select",t)
			return;
		}
		//没有就创建
       $("#tt").tabs("add",{
    	   id:funId,//二级功能ID
    	   title:t,//标题
    	   href:h,//得到访问路径
    	   closable:true,//是否关闭
    	   selected:true//是否选中
       })
	});
	
	//当用户点击移除，关闭当前打开的选项卡
	$("#tab-remove").click(function(){
		//获取选中的标签页面板
		var tab = $("#tt").tabs("getSelected");
		var index = $("#tt").tabs("getTabIndex",tab);
		//如果是工作台就不关闭
		if(index==0){
			return;
		}
		$("#tt").tabs("close",index);
	});
	
	//关闭所有
	$("#tab-clear").click(function(){
		var tabs = $("#tt").tabs("tabs");
		for(var i=tabs.length-1;i>0;i--){
			$("#tt").tabs("close",i);
		}
	});
	
	$("#tuichu").click(function(){
		//alert("退出登陆");
		$.ajax({
			url:"zhuxiao",
			type:'post',
			 success:function(){				    	
				  window.location.href="Land"; 
		    }
		});	
	});	

	//排班班次初始化
	$.ajax({
		url:'init_arrange_classes',
		type:'post',
		dataType:'json',
		success:function(data){
			//console.log("排班班次--------------："+data);
			//医生早班
			$(".doc_morning").text(data[0].arrange_starclassses+"—"+data[0].arrange_endclassses);
			$(".doc_morningid").text(data[0].arrange_classsid);
			//医生中班
			$(".doc_evening").text(data[1].arrange_starclassses+"—"+data[1].arrange_endclassses);
			$(".doc_eveningid").text(data[1].arrange_classsid);
			//医生晚班
			$(".doc_night").text(data[2].arrange_starclassses+"—"+data[2].arrange_endclassses);
			$(".doc_nightid").text(data[2].arrange_classsid);
			//护士早班
			$(".nurse_morning").text(data[3].arrange_starclassses+"—"+data[3].arrange_endclassses);
			$(".nurse_morningid").text(data[3].arrange_classsid);
			//护士中班
			$(".nurse_evening").text(data[4].arrange_starclassses+"—"+data[4].arrange_endclassses);
			$(".nurse_eveningid").text(data[4].arrange_classsid);
			//护士晚班
			$(".nurse_night").text(data[5].arrange_starclassses+"—"+data[5].arrange_endclassses);
			$(".nurse_nightid").text(data[5].arrange_classsid);
		}
	});
	
	//点击折叠的里面按钮动态创建选项卡
	$(".fun").click(function(){
		//获取按钮内容
		var t=$(this).text();
		//路径
		var h=$(this).attr("data-href");
		var funId = $(this).attr("data-id");
		//有着按钮就打开
		if($("#tt").tabs("exists",t)){
			$("#tt").tabs("select",t)
			return;
		}
		//没有就创建
       $("#tt").tabs("add",{
    	   id:funId,//二级功能ID
    	   title:t,//标题
    	   href:h,//得到访问路径
    	   closable:true,//是否关闭
    	   selected:true//是否选中
       })
	});
	
	//当用户点击移除，关闭当前打开的选项卡
	$("#tab-remove").click(function(){
		//获取选中的标签页面板
		var tab = $("#tt").tabs("getSelected");
		var index = $("#tt").tabs("getTabIndex",tab);
		//如果是工作台就不关闭
		if(index==0){
			return;
		}
		$("#tt").tabs("close",index);
	});
	
	//关闭所有
	$("#tab-clear").click(function(){
		var tabs = $("#tt").tabs("tabs");
		for(var i=tabs.length-1;i>0;i--){
			$("#tt").tabs("close",i);
		}
	});
	
   
	 //排班表格初始化
	//获取系统当天时间
	 var curdate = new Date();
	 var curdate_format=formatDate(curdate);
	 //日期显示
	 $("#datetext").text(curdate_format);
	 //将今天的日期存储下来
	 $("#arrangetoday").val(curdate_format);
	 //console.log("排班表格初始化当天时间："+curdate_format);
	$("#arrange-tab").datagrid({
		  url:'init-All-arrange-record?curdate_format='+curdate_format,
		  //fitColumns:true,//宽度自适应
		  columns:[
			  [
			    {field:'section_type',title:'类型',width:83,height:50,rowspan:3},
				{field:'section_name',title:'科室',width:123,height:50,rowspan:3},
				{field:'section_id',title:'科室编号',width:80,rowspan:3,hidden:true},
	    	 	{field:'morning_classes',title:'早',width:275,colspan:2},
	    	 	{field:'middle_classes',title:'中',width:275,colspan:2},
	    		{field:'night_classes',title:'晚',width:274,colspan:2}
	   		 ],
		    [
		    	{field:'role_morclasses',title:'医生',width:137.5},
	    	 	{field:'2',title:'护士',width:137.5},
	    		{field:'3',title:'医生',width:137.5},
	    	 	{field:'4',title:'护士',width:137.5},
	    	 	{field:'3',title:'医生',width: 136},
	    		{field:'3',title:'护士',width:136}
		    ],
		     [
		    	{field:'morning_doctor',title:'08:00—17:00',width:137.5,
		    	   formatter: function(value,row,index){
		    		  var morningdoctor="";
		    		  for (var i = 0; i < value.length; i++) {
	    				   if(i>0){
	    	    				morningdoctor+="<a  class='morningdocname'   style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
	    	                }else{
			                     morningdoctor+="<a  class='morningdocname' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
	    	                }
					  }
		    		  return morningdoctor;
		    	   }	
		    	},
	    	 	{field:'morning_nurse',title:'07:30—15:30',width:137.5,
			    	   formatter: function(value,row,index){
			    		  var morningnurse="";
			    		  for (var i = 0; i < value.length; i++) {
			    				//console.log("-------------"+value[i].hushi);
			    				 if(i>0){
			   					  morningnurse += "<a  class='morningnurname'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
			   	              }else{
			   	            	  morningnurse += "<a  class='morningnurname' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
			   	              }
						   }
				    		  return morningnurse;
				        }	
		    	 },
	    		{field:'middle_doctor',title:'17:00—01:00',width:137.5,
			    	   formatter: function(value,row,index){
				    		  var middledoctor="";
				    		  for (var i = 0; i < value.length; i++) {
			    				   if(i>0){
			    					    middledoctor+="<a  class='middledoctor'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
			    	                }else{
			    	                	middledoctor+="<a  class='middledoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
			    	                }
							  }
				    		  return middledoctor;
				    	   }	
		    	 },
	    	 	{field:'middle_nurse',title:'15:30—23:30',width:137.5,
			    	   formatter: function(value,row,index){
				    		  var middlenurse="";
				    		  for (var i = 0; i < value.length; i++) {
				    				 if(i>0){
				    					  middlenurse += "<a  class='middlenurse'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
					   	              }else{
					   	            	middlenurse += "<a  class='middlenurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
					   	              }
							   }
					    		  return middlenurse;
					        }	},
	    	 	{field:'night_doctor',title:'01:00—08:00',width: 136,
			    	   formatter: function(value,row,index){
				    		  var nightdoctor="";
				    		  for (var i = 0; i < value.length; i++) {
			    				   if(i>0){
			    					   nightdoctor+="<a  class='nightdoctor'   style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
			    	                }else{
			    	                	nightdoctor+="<a  class='nightdoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
			    	                }
							  }
				    		  return nightdoctor;
				    	   }	
				 },
	    		{field:'night_nurse',title:'23:30—07:30',width:138,
					 formatter: function(value,row,index){
		    		  var nightnurse="";
		    		  for (var i = 0; i < value.length; i++) {
	    				   if(i>0){
	    					    nightnurse+="<a  class='nightnurse'   style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
	    	                }else{
	    	                	nightnurse+="<a  class='nightnurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
	    	                }
					  }
		    		  return nightnurse;
		    	   }	
				}
		    ]]
	});
	 
	
	//前一天
	$('#beforeday').click(function(){
		 //alert("前一天按钮！！！");
		  var today=$("#datetext").text();
		  var preDate_format=dateJian(today);
		  //日期显示
		  $("#datetext").text(preDate_format);
		  //console.log("前一天:"+preDate_format); 
			$("#arrange-tab").datagrid({
				  url:'init-All-arrange-record?curdate_format='+preDate_format,
				  //fitColumns:true,//宽度自适应
				  columns:[
					  [
					    {field:'section_type',title:'类型',width:83,height:50,rowspan:3},
						{field:'section_name',title:'科室',width:123,height:50,rowspan:3},
						{field:'section_id',title:'科室编号',width:80,rowspan:3,hidden:true},
			    	 	{field:'morning_classes',title:'早',width:275,colspan:2},
			    	 	{field:'middle_classes',title:'中',width:275,colspan:2},
			    		{field:'night_classes',title:'晚',width:274,colspan:2}
			   		 ],
				    [
				    	{field:'role_morclasses',title:'医生',width:137.5},
			    	 	{field:'2',title:'护士',width:137.5},
			    		{field:'3',title:'医生',width:137.5},
			    	 	{field:'4',title:'护士',width:137.5},
			    	 	{field:'3',title:'医生',width: 136},
			    		{field:'3',title:'护士',width:136}
				    ],
				     [
				    	{field:'morning_doctor',title:'08:00—17:00',width:137.5,
				    	   formatter: function(value,row,index){
				    		  var morningdoctor="";
				    		  for (var i = 0; i < value.length; i++) {
			    				   if(i>0){
			    	    				morningdoctor+="<a  class='morningdocname'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
			    	                }else{
					                     morningdoctor+="<a  class='morningdocname' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
			    	                }
							  }
				    		  return morningdoctor;
				    	   }	
				    	},
			    	 	{field:'morning_nurse',title:'07:30—15:30',width:137.5,
					    	   formatter: function(value,row,index){
					    		  var morningnurse="";
					    		  for (var i = 0; i < value.length; i++) {
					    				console.log("-------------"+value[i].hushi);
					    				 if(i>0){
					   					  morningnurse += "<a  class='morningnurname'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
					   	              }else{
					   	            	  morningnurse += "<a  class='morningnurname' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
					   	              }
								   }
						    		  return morningnurse;
						        }	
				    	 },
			    		{field:'middle_doctor',title:'17:00—01:00',width:137.5,
					    	   formatter: function(value,row,index){
						    		  var middledoctor="";
						    		  for (var i = 0; i < value.length; i++) {
					    				   if(i>0){
					    					    middledoctor+="<a  class='middledoctor'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
					    	                }else{
					    	                	middledoctor+="<a  class='middledoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
					    	                }
									  }
						    		  return middledoctor;
						    	   }	
				    	 },
			    	 	{field:'middle_nurse',title:'15:30—23:30',width:137.5,
					    	   formatter: function(value,row,index){
						    		  var middlenurse="";
						    		  for (var i = 0; i < value.length; i++) {
						    				 if(i>0){
						    					  middlenurse += "<a  class='middlenurse'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
							   	              }else{
							   	            	middlenurse += "<a  class='middlenurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
							   	              }
									   }
							    		  return middlenurse;
							        }	},
			    	 	{field:'night_doctor',title:'01:00—08:00',width: 136,
					    	   formatter: function(value,row,index){
						    		  var nightdoctor="";
						    		  for (var i = 0; i < value.length; i++) {
					    				   if(i>0){
					    					   nightdoctor+="<a  class='nightdoctor'   style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
					    	                }else{
					    	                	nightdoctor+="<a  class='nightdoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
					    	                }
									  }
						    		  return nightdoctor;
						    	   }	
						 },
			    		{field:'night_nurse',title:'23:30—07:30',width:138,
							 formatter: function(value,row,index){
				    		  var nightnurse="";
				    		  for (var i = 0; i < value.length; i++) {
			    				   if(i>0){
			    					    nightnurse+="<a  class='nightnurse'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
			    	                }else{
			    	                	nightnurse+="<a  class='nightnurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
			    	                }
							  }
				    		  return nightnurse;
				    	   }	
						}
				    ]]
			});
		 
    }); 
	
	//后一天
	$('#afterday').click(function(){
		 //alert("后一天按钮！！！");
		 var today=$("#datetext").text();
		 //alert("today:"+today);
		 var nextDate_format=dateAdd(today);
		 $("#datetext").text(nextDate_format);
		 //console.log("后一天:"+nextDate_format); 
		 $("#arrange-tab").datagrid({
			  url:'init-All-arrange-record?curdate_format='+nextDate_format,
			  //fitColumns:true,//宽度自适应
			  columns:[
				  [
				    {field:'section_type',title:'类型',width:83,height:50,rowspan:3},
					{field:'section_name',title:'科室',width:123,height:50,rowspan:3},
					{field:'section_id',title:'科室编号',width:80,rowspan:3,hidden:true},
		    	 	{field:'morning_classes',title:'早',width:275,colspan:2},
		    	 	{field:'middle_classes',title:'中',width:275,colspan:2},
		    		{field:'night_classes',title:'晚',width:274,colspan:2}
		   		 ],
			    [
			    	{field:'role_morclasses',title:'医生',width:137.5},
		    	 	{field:'2',title:'护士',width:137.5},
		    		{field:'3',title:'医生',width:137.5},
		    	 	{field:'4',title:'护士',width:137.5},
		    	 	{field:'3',title:'医生',width: 136},
		    		{field:'3',title:'护士',width:136}
			    ],
			     [
			    	{field:'morning_doctor',title:'08:00—17:00',width:137.5,
			    	   formatter: function(value,row,index){
			    		  var morningdoctor="";
			    		  for (var i = 0; i < value.length; i++) {
		    				   if(i>0){
		    	    				morningdoctor+="<a  class='morningdocname'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
		    	                }else{
				                     morningdoctor+="<a  class='morningdocname' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
		    	                }
						  }
			    		  return morningdoctor;
			    	   }	
			    	},
		    	 	{field:'morning_nurse',title:'07:30—15:30',width:137.5,
				    	   formatter: function(value,row,index){
				    		  var morningnurse="";
				    		  for (var i = 0; i < value.length; i++) {
				    				//console.log("-------------"+value[i].hushi);
				    				 if(i>0){
				   					  morningnurse += "<a  class='morningnurname'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
				   	              }else{
				   	            	  morningnurse += "<a  class='morningnurname' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
				   	              }
							   }
					    		  return morningnurse;
					        }	
			    	 },
		    		{field:'middle_doctor',title:'17:00—01:00',width:137.5,
				    	   formatter: function(value,row,index){
					    		  var middledoctor="";
					    		  for (var i = 0; i < value.length; i++) {
				    				   if(i>0){
				    					    middledoctor+="<a  class='middledoctor'   style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
				    	                }else{
				    	                	middledoctor+="<a  class='middledoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
				    	                }
								  }
					    		  return middledoctor;
					    	   }	
			    	 },
		    	 	{field:'middle_nurse',title:'15:30—23:30',width:137.5,
				    	   formatter: function(value,row,index){
					    		  var middlenurse="";
					    		  for (var i = 0; i < value.length; i++) {
					    				 if(i>0){
					    					  middlenurse += "<a  class='middlenurse'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
						   	              }else{
						   	            	middlenurse += "<a  class='middlenurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
						   	              }
								   }
						    		  return middlenurse;
						        }	},
		    	 	{field:'night_doctor',title:'01:00—08:00',width: 136,
				    	   formatter: function(value,row,index){
					    		  var nightdoctor="";
					    		  for (var i = 0; i < value.length; i++) {
				    				   if(i>0){
				    					   nightdoctor+="<a  class='nightdoctor'  style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
				    	                }else{
				    	                	nightdoctor+="<a  class='nightdoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
				    	                }
								  }
					    		  return nightdoctor;
					    	   }	
					 },
		    		{field:'night_nurse',title:'23:30—07:30',width:138,
						 formatter: function(value,row,index){
			    		  var nightnurse="";
			    		  for (var i = 0; i < value.length; i++) {
		    				   if(i>0){
		    					    nightnurse+="<a  class='nightnurse'   style='text-align:center,border-bottom:1px solid #ccc;border-top:1px solid #ccc;border-width:1px 0 0 0;border-style: dotted;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
		    	                }else{
		    	                	nightnurse+="<a  class='nightnurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
		    	                }
						  }
			    		  return nightnurse;
			    	   }	
					}
			    ]]
		});
		 
    });
	
	//今天
	$('#todaydate').click(function(){
		 //$("#arrange-tab").datagrid('reload'); 
		 var curdate_format=formatDate(curdate);
		 $("#datetext").text(curdate_format);
		 $("#arrange-tab").datagrid({
			  url:'init-All-arrange-record?curdate_format='+curdate_format,
			  //fitColumns:true,//宽度自适应
			  columns:[
				  [
				    {field:'section_type',title:'类型',width:83,height:50,rowspan:3},
					{field:'section_name',title:'科室',width:123,height:50,rowspan:3},
					{field:'section_id',title:'科室编号',width:80,rowspan:3,hidden:true},
		    	 	{field:'morning_classes',title:'早',width:275,colspan:2},
		    	 	{field:'middle_classes',title:'中',width:275,colspan:2},
		    		{field:'night_classes',title:'晚',width:274,colspan:2}
		   		 ],
			    [
			    	{field:'role_morclasses',title:'医生',width:137.5},
		    	 	{field:'2',title:'护士',width:137.5},
		    		{field:'3',title:'医生',width:137.5},
		    	 	{field:'4',title:'护士',width:137.5},
		    	 	{field:'3',title:'医生',width: 136},
		    		{field:'3',title:'护士',width:136}
			    ],
			     [
			    	{field:'morning_doctor',title:'08:00—17:00',width:137.5,
			    	   formatter: function(value,row,index){
			    		  var morningdoctor="";
			    		  for (var i = 0; i < value.length; i++) {
		    				   if(i>0){
		    	    				morningdoctor+="<a  class='morningdocname'  style='text-align:center,border-bottom:1px solid #eee;border-top:1px solid #eee;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
		    	                }else{
				                     morningdoctor+="<a  class='morningdocname' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
		    	                }
						  }
			    		  return morningdoctor;
			    	   }	
			    	},
		    	 	{field:'morning_nurse',title:'07:30—15:30',width:137.5,
				    	   formatter: function(value,row,index){
				    		  var morningnurse="";
				    		  for (var i = 0; i < value.length; i++) {
				    				console.log("-------------"+value[i].hushi);
				    				 if(i>0){
				   					  morningnurse += "<a  class='morningnurname' style='text-align:center,border-bottom:1px solid #eee;border-top:1px solid #eee;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
				   	              }else{
				   	            	  morningnurse += "<a  class='morningnurname' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
				   	              }
							   }
					    		  return morningnurse;
					        }	
			    	 },
		    		{field:'middle_doctor',title:'17:00—01:00',width:137.5,
				    	   formatter: function(value,row,index){
					    		  var middledoctor="";
					    		  for (var i = 0; i < value.length; i++) {
				    				   if(i>0){
				    					    middledoctor+="<a  class='middledoctor'  style='text-align:center,border-bottom:1px solid #eee;border-top:1px solid #eee;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
				    	                }else{
				    	                	middledoctor+="<a  class='middledoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
				    	                }
								  }
					    		  return middledoctor;
					    	   }	
			    	 },
		    	 	{field:'middle_nurse',title:'15:30—23:30',width:137.5,
				    	   formatter: function(value,row,index){
					    		  var middlenurse="";
					    		  for (var i = 0; i < value.length; i++) {
					    				 if(i>0){
					    					  middlenurse += "<a  class='middlenurse' style='text-align:center,border-bottom:1px solid #eee;border-top:1px solid #eee;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
						   	              }else{
						   	            	middlenurse += "<a  class='middlenurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
						   	              }
								   }
						    		  return middlenurse;
						        }	},
		    	 	{field:'night_doctor',title:'01:00—08:00',width: 136,
				    	   formatter: function(value,row,index){
					    		  var nightdoctor="";
					    		  for (var i = 0; i < value.length; i++) {
				    				   if(i>0){
				    					   nightdoctor+="<a  class='nightdoctor'  style='text-align:center,border-bottom:1px solid #eee;border-top:1px solid #eee;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].yishen+" </a>"+"</br>";
				    	                }else{
				    	                	nightdoctor+="<a  class='nightdoctor' style='text-align:center'>"+value[i].yishen+" </a>"+"</br>";
				    	                }
								  }
					    		  return nightdoctor;
					    	   }	
					 },
		    		{field:'night_nurse',title:'23:30—07:30',width:138,
						 formatter: function(value,row,index){
			    		  var nightnurse="";
			    		  for (var i = 0; i < value.length; i++) {
		    				   if(i>0){
		    					    nightnurse+="<a  class='nightnurse'  style='text-align:center,border-bottom:1px solid #eee;border-top:1px solid #eee;display: inline-block; width: 137.5px;height: 20px;margin-left: -6px;'>"+value[i].hushi+" </a>"+"</br>";
		    	                }else{
		    	                	nightnurse+="<a  class='nightnurse' style='text-align:center'>"+value[i].hushi+" </a>"+"</br>";
		    	                }
						  }
			    		  return nightnurse;
			    	   }	
					}
			    ]]
		});
	});
	
	//双击排班表格----新增排班
	$("#arrange-tab").datagrid({
		//onDblClickRow
		onDblClickCell: function(index,field,value){
			var rowsdata=$("#arrange-tab").datagrid("getRows");
			//通过点击单元格的索引----获取科室名称与科室id
			var section_name=rowsdata[index].section_name;
			var section_id=rowsdata[index].section_id;	
			$("#sections").combobox("select",section_id);
			//排班班次
			var title_arrange_classes;
			
			if(field=="morning_doctor"){
				//医生早班
				title_arrange_classes=$(".doc_morningid").text();
				$("#arrange_role").val("医生");
			}
			 
			 if(field=="middle_doctor"){
				//医生中班
				title_arrange_classes=$(".doc_eveningid").text();
				$("#arrange_role").val("医生");
			 } 
			 
			 if(field=="night_doctor"){
				//医生晚班
				title_arrange_classes=$(".doc_nightid").text();
				$("#arrange_role").val("医生");
			  }
			
			 if(field=="morning_nurse"){
				 //alert("早---"+field)
				//护士早班
				title_arrange_classes=$("#nurse_morning_id").text();
				$("#arrange_role").val("护士");
			 } 
			
			 if(field=="middle_nurse"){
				 //alert("中---"+field)
				//护士中班
				title_arrange_classes=$(".nurse_eveningid").text();
				$("#arrange_role").val("护士");
			 } 
			 
			 if(field=="night_nurse"){
				//护士晚班
				title_arrange_classes=$(".nurse_nightid").text();
				$("#arrange_role").val("护士");
			 } 
			 //alert(field+"-----:"+title_arrange_classes+"--------"+title_arrange_classes);
			 $(".arrangeClassid").combobox("setValue",title_arrange_classes);
			 
			//alert("当前行科室----："+section_name+"------科室id："+section_id+"----班次id:"+title_arrange_classes);
	     	//获取切换时间
			var now=$("#datetext").text();
			//alert("now："+now);
			//排班时间
			var order_date=$("#arrangetoday").val();
			//alert("order_date："+order_date);
	
			//第一步---只能对当天或者以后来新增排班-----当天排班系统时间<切换的时间
			if(Date.parse(now)==Date.parse(order_date) || Date.parse(order_date)<Date.parse(now)){
				//alert("排班now："+now+"排班order_date："+order_date);
				//获取当前系统时间后一天设置默认日期
				 var nextDate_format_text=dateAdd(now);
				$("#orderclass_time").datebox("setValue",nextDate_format_text);
				//第二步----有相对于权限的人才可调整排班班次
				$.ajax({
					url:'If-arrangeAdd',
					type:'post',
					success:function(data){
						//有此权限打开弹框
						if(parseInt(data)==1){
							//console.log("有此权限打开弹框:"+data);
							//打开弹框
							//$("#arrange-Addwin").window("open");
							$("#order_class-addtabs-win").window("open");
						}
						//无此权限---弹框提示
						if(parseInt(data)==0){
							//console.log("无此权限---弹框提示:"+data);
							$.messager.confirm('Confirm', 
									'很抱歉，你的权限不足！！', 
									function(r){
						     });
						}
					}
				});
				
			}else{
				 $.messager.confirm('Confirm', 
							'以往记录不可新增排班', 
							function(r){
				 });
			}
			
			//排班人员
			$("#orderclass_startime").combobox({
				onChange: function (newValue, oldValue){
					//排班科室
					var users_section=$("#sections").combobox("getValue");
					//人员
					var users=$("#section-people").combobox("getValue");
					//选择的日期
					var order_datetime=$("#orderclass_time").datebox("getValue");
				    //选择的开始与结束时间
				    var starEndtime=$("#orderclass_startime").combobox("getValue");
					//alert("users_section:"+users_section+"---users:"+users+"--------order_datetime:"+order_datetime+"----------startime:"+starEndtime);
				    $.ajax({
						 type: "Post",
						 url: "if-userArrange",
						 dataType : "json",
						 data:{
							 'users_section':users_section,
							 'user_id':users,
							 'order_datetime':order_datetime,
							 'starEndtime':starEndtime
						 },
						 success: function(data){
							      //alert(data.orderclass_id);
							     if(typeof(data.orderclass_id)!="undefined"){
							    	 $.messager.confirm('Confirm', 
										    '已经存在相同排班,是否对已经存在排班进行修改', 
											function(b){
									    		 if (b){
									    			     //新增按钮隐藏
									    			     $("#arrange-submit-field").hide();
									    			     //修改按钮显示
									    			 	 $("#arrangeUpdate-submit").show();
									    	             // alert('确认修改');
									    	             //原来班次--用于修改
									    			 	 var arrangclass=$("#orderclass_startime").combobox("getValue");
									    	             $("#arrange_classID").val(arrangclass);
									    	             //原来日期
									    	             var old_orderclass_time=$("#orderclass_time").datebox("getValue");
									    	             $("#arrange_classTime").val(old_orderclass_time); 
									    		 }else{
									    	           // alert('取消');
									    	      }

									     }
							    	 );
							     }//if传过来的排班主键不为空
							 }
						 }); 
			     }
			});
		}
	});
	
	//新增排班提交
	$("#arrange-submit").click(function(){
		var rowdats=$("#order_class-addtabs").datagrid("getRows");
		if(rowdats.length==0){
			$.messager.confirm('Confirm', 
				'表格不能为空,请添加排班人员！！', 
				function(r){
			});
			return false;
		}else{
		$("<form method='post' id='for'>").appendTo("body").form({
			   url:'addorder_class',
			   onSubmit:function(param){
				    var rows=$("#order_class-addtabs").datagrid("getRows");
					for(var  i = 0;i < rows.length; i++){
					    //排班班次id
					    param["orderclass["+i+"].arrangeClass.arrangeClasssid"]= rows[i]["arrange_id"];
					    console.log("排班班次："+ param["orderclass["+i+"].arrangeClass.arrangeClasssid"]);
					 
					     //用户id
					    param["orderclass["+i+"].user.userId"] = rows[i]["user_id"];
					    console.log("用户id："+  param["orderclass["+i+"].user.userId"]);
						
					    //排班日期
					    param["orderclass["+i+"].orderclassTime"]= new Date(rows[i]["arrange_dates"].replace(/-/g, "/"));  
					    console.log("排班日期："+ param["orderclass["+i+"].orderclassTime"]);
					}
				  
				},
		      success:function(data){
		    	  if(parseInt(data)==1){
		    		  $(".window-tishi").text("排班人员新增成功！！！");
				    	$("#saveclinic-win").window('open');
				    	//三秒之后自动消失
					   setTimeout(function(){
					    	 $("#saveclinic-win").window('close');
						  }, 2000);
				    	 //关闭窗口
				    	 $("#order_class-addtabs-win").window('close');
				    	 //排班表刷新
				    	 $('#arrange-tab').datagrid('reload');
				    	 //新增表格清空
				    	 $("#order_class-addtabs").datagrid("loadData", {total:0, rows:[]});
				    	 //刷新下拉框
				    	 $('#section-people').combobox('reload');
				    	 $('#sections').combobox('reload');
				    	 $('#orderclass_startime').combobox('reload');
		    	  }
		    	  
				 if(parseInt(data)==2){
					    $(".window-tishi").text("排班新增失败,请稍后重试....");
				    	$("#saveclinic-win").window('open');
				    	//三秒之后自动消失
					   setTimeout(function(){
					    	 $("#saveclinic-win").window('close');
						  }, 2000);
					      //关闭窗口
				    	 $("#order_class-addtabs-win").window('close');
				    	 //排班表刷新
				    	 $('#arrange-tab').datagrid('reload');
				    	 //新增表格清空
				    	 $("#order_class-addtabs").datagrid("loadData", {total:0, rows:[]});
				    	 //刷新下拉框
				    	 $('#section-people').combobox('reload');
				    	 $('#sections').combobox('reload');
				    	 $('#orderclass_startime').combobox('reload');
		    	 } 
		      }
		   }).submit();
		}
	}); 
	
	//三级联动---科室---人员---班次
	 $('#sections').combobox({   
	   	  url:'init-arrangesection',//数据源
	      valueField: 'section_id',//实体类名字---主键id
	      textField: 'section_name',//需要显示在下拉框的实际内容
	      editable:false,
	      onSelect:function(r){
	    	  //获取选中的科室id
	    	  var sid= r["section_id"];
	    	  //根据科室id初始化科室下面对应的人员---url地址
	    	  var url='init-arrangeuser';
	    	  var role_name=$("#arrange_role").val();
	    	  $.post(url,{sid:sid,role_name:role_name},function(result){//二级联动
	    		  $('#section-people').combobox({   
	    			  data:result,
	    		      valueField: 'user_id',//实体类名字---主键id
	    		      textField: 'user_name',//需要显示在下拉框的实际内容
	    		      editable:false,
	    		      panelHeight:'auto',
	    		      onLoadSuccess: function () { //加载完成后,设置选中的项 
                        $("#section-people").combobox('select',result[0].user_id);
                      },
                      onSelect:function(record){
                    	  //获取选中的人员id
            	    	  var userid= record["user_id"];
            	    	  //根据用户id---url地址
            	    	  var url_t='init-arrangeclasses';
            	    	  //根据用户id初始化班次
 						  $.post(url_t,{userid:userid}, function(user_result){//三级联动
 							  //console.log("user_result[0].arrange_starclassses:"+user_result[0].arrange_starclassses);
 							 // console.log("user_result[0].arrange_endclassses:"+user_result[0].arrange_endclassses);
 							 //开始时间
 							 $(".arrangeClassid").combobox({   
 								  data:user_result,
 							      valueField: 'arrange_classsid',//实体类名字---主键id
 							      textField: 'arrange_starclassses',//需要显示在下拉框的实际内容
 							      editable:false, 
 							      panelHeight:'auto' ,
 							      onLoadSuccess: function(){ //加载完成后,设置选中的项 
 							    	 $(".arrangeClassid").combobox('select',user_result[0].arrange_classsid);
 			                      },
								 onSelect:function(datas){
									 //获取开始时间的班次id
									 var arrangeclass_ids= datas["arrange_classsid"];
									 var urls='init-arrangeclasses-endclass';
									 $.post(urls,{arrangeclass_ids:arrangeclass_ids}, function(end_result){
										 $(".arrangeClassid_end").combobox({   
			 								  data:end_result,
			 							      valueField: 'arrange_classsid',//实体类名字---主键id
			 							      textField: 'arrange_endclassses',//需要显示在下拉框的实际内容+"—"+'arrange_endclassses'
			 							      editable:false, 
			 							      panelHeight:'auto',
			 								  onLoadSuccess: function () { //加载完成后,设置选中的项 
			 									 $(".arrangeClassid_end").combobox('select',end_result[0].arrange_classsid);
			 									 //$(".arrangeClassid_end").combobox('readonly',true); 
			 			                      }
										 }); 
									 },'json');//结束班次
								 }
 							  });//开始班次combobox
            	    	  },'json');//3级----post
            	    	  
                      }//人员下拉选中--select
	    		  });//人员combbox
	    	  
	    	  },'json');//2级--post
	    	  
	    	 },//科室下拉选中--select
    	    onLoadSuccess: function () {  //加载完成后,设置选中第一项
	              var val = $(this).combobox("getData");
	              for (var item in val[0]) {
	                  if (item == "section_id") {
	                  	//初始化数据默认选中第一个
	                      $(this).combobox("select", val[0][item]);
	                  }
	              }
	        }
	    	 
	      });

	
	//修改班次
	$("#kindly-reminder").click(function(){
		//打开弹框
		$("#kindly-reminder-win").window("open");
	});
	  

     //修改按钮隐藏
	$("#arrangeUpdate-submit").hide();
	
	//修改
	$("#arrangeUpdate-submit").click(function(){
		 //原来班次--用于修改
	 	 var old_arrangeclass_id=$("#arrange_classID").val();
	 	 //原来排班日期
	 	 var  old_arrange_classTime=$("#arrange_classTime").val();
	 	 //修改之后的排班班次
         var Ordertimes=$("#orderclass_startime").combobox("getValue");
         //修改的日期
         var  Orderdates=$("#orderclass_time").datebox("getValue");
		 var section_id= $('#sections').combobox('getValue');
		 var user_id=$('#section-people').combobox('getValue');
		 //alert("section_id----"+section_id+"user_id:"+user_id+"修改的排班班次:"+old_arrangeclass_id+"---------日期-"+Orderdates);
		$.ajax({
				 type: "Post",
				 url: "update-arrangeClass",
				 dataType : "json",
				 data:{
					 'arrangeclass_id':Ordertimes,
					 'orderclass_time':Orderdates,
					 'section_id':section_id,
					  'user_id':user_id,
					  'old_arrangeclass_id':old_arrangeclass_id,
					  'old_arrange_classTime':old_arrange_classTime
				 },
				 success: function(data){
					 //成功
					 if(parseInt(data)==1){
					   $(".window-tishi").text("调整排班班次成功！！！");
					   $("#saveclinic-win").window('open');
				       //三秒之后自动消失
					   setTimeout(function(){
					    	 $("#saveclinic-win").window('close');
					   }, 2000);
					      //关闭窗口
				    	 $("#order_class-addtabs-win").window('close');
				    	 //新增按钮显示
	    			     $("#arrange-submit-field").show();
	    			     //修改按钮隐藏
	    			 	 $("#arrangeUpdate-submit").hide();
				    	 //排班表刷新
				    	 $('#arrange-tab').datagrid('reload');
				    	 //新增表格清空
				    	 $("#order_class-addtabs").datagrid("loadData", {total:0, rows:[]});
				    	 //刷新下拉框
				    	 $('#section-people').combobox('reload');
				    	 $('#sections').combobox('reload');
				    	 $('#orderclass_startime').combobox('reload');
   			    	 
					 }
					 
					 if(parseInt(data)==2){
						   $(".window-tishi").text("调整排班班次失败,请重试......");
						   $("#saveclinic-win").window('open');
					       //三秒之后自动消失
						   setTimeout(function(){
						    	 $("#saveclinic-win").window('close');
						   }, 2000);
					       //关闭窗口
				    	   $("#order_class-addtabs-win").window('close');
				    	   //排班表刷新
				    	   $('#arrange-tab').datagrid('reload');
				    	   //新增表格清空
				    	   $("#order_class-addtabs").datagrid("loadData", {total:0, rows:[]});
				    	   //刷新下拉框
				    	   $('#section-people').combobox('reload');
				    	   $('#sections').combobox('reload');
				    	   $('#orderclass_startime').combobox('reload');
					 }
					
				 }
			 });
	});
	//多人排班的追加表格
	$("#order_class-addtabs").datagrid({
		  columns:[[
			    {field:'section_id',title:'科室',hidden:true},
			    {field:'section_name',title:'科室',width:90},
			    {field:'user_id',title:'用户',width:90,hidden:true},
				{field:'user_name',title:'用户',width:100},
				{field:'arrange_id',title:'班次id',width:103,hidden:true},
	    	 	{field:'star_classes',title:'开始班次',width:90},
	    	 	{field:'end_classes',title:'结束班次',width:90},
	    	 	{field:'arrange_dates',title:'排班日期',width:110},
	    		{field:'arrange_dates_work',title:'操作',width:45,
	    	 		formatter:function(value,row,index){
						 return  "<a onclick='arrange_remove("+index+")'>移除</a>"
						
					}	
	    		}
	   		 ]]
	});
	
	//提交到排班列表
	$("#arrange-submit-field").click(function(){
		
			//科室
			var section_id=$("#sections").combobox("getValue");
			var section_name=$("#sections").combobox("getText");
			//用户
			var user_id=$("#section-people").combobox("getValue");
			var user_name=$("#section-people").combobox("getText");
			//班次id
			var arrange_id=$("#orderclass_startime").combobox("getValue");
			//开始班次
			var arrange_starclass=$("#orderclass_startime").combobox("getText");
			//结束班次
			var arrange_endclass=$("#orderclass_endtime").combobox("getText");
	        //日期
	        var orderclass_time=$("#orderclass_time").datebox("getValue");
			
			console.log("科室id-----："+section_id+"----用户id："+user_id);
			
			$("#order_class-addtabs").datagrid('appendRow',{
				 section_id:section_id,
				 section_name:section_name,
				 user_id:user_id,
				 user_name:user_name,
				 arrange_id:arrange_id,
				 star_classes:arrange_starclass,
				 end_classes:arrange_endclass,
				 arrange_dates:orderclass_time
	         });	
		
	});
	
});	

//------后一天
function dateAdd(startDate) {
	        startDate = new Date(startDate);
	        startDate = +startDate + 1000*60*60*24;
	        startDate = new Date(startDate);
	        var nextStartDate = startDate.getFullYear()+"-"+formatTen((startDate.getMonth()+1))+"-"+formatTen(startDate.getDate());
	        return nextStartDate;
}                           

//点击减一天-------前一天
function dateJian(startDate){
	        startDate = new Date(startDate);
	        startDate =+startDate - 1000*60*60*24;
	        startDate = new Date(startDate);
	        var nextStartDate = startDate.getFullYear()+"-"+formatTen((startDate.getMonth()+1))+"-"+formatTen(startDate.getDate());
	        return nextStartDate;
}

//转换日期格式
function formatDate(date) { 
	var year = date.getFullYear(); 
	var month = date.getMonth() + 1; 
	var day = date.getDate(); 
	var hour = date.getHours(); 
	var minute = date.getMinutes(); 
	var second = date.getSeconds(); 
	return year + "-" + formatTen(month) + "-" + formatTen(day); 
}

function formatTen(num) { 
	return num > 9 ? (num + "") : ("0" + num); 
}

//排班日期
function selecttime(){
	 var curdate = new Date();
	 var present_format=formatDate(curdate);
	//获取日期--如果选择的日期小于当前日期弹框提示
	var order_datetime=$("#orderclass_time").datebox("getValue");
	//alert(order_datetime);
	//选择的日期<当前日期
	if(Date.parse(order_datetime)<Date.parse(present_format) || Date.parse(order_datetime)==Date.parse(present_format)){
		 $.messager.confirm('Confirm', 
					'请重新选择今天以后的日期', 
					function(r){
		 });
	}
	 
}

//排班移除表格一行
function arrange_remove(index){
	 $.messager.confirm('Confirm', 
			    '确定移除', 
				function(b){
		           if(b){
		        	   $('#order_class-addtabs').datagrid('deleteRow', index);
		           }
	            }
	 )
	
}


//合并单元格
function Mergerows(data){
		var start = 0;
		var end = 0;
		var mer = ['section_type'];//需要合并的字段，即field
		//有数据就合并----对应数据的数量
		if (data.total > 0){
			//console.log("data.total:"+data.total);
		    var temp = data.rows[0].section_type;   //需要比较的列-----排班类型----门诊还是住院
		    for (var i = 1; i < data.rows.length; i++) {
			    //第一列的门诊或住院类型=遍历过程中的门诊或住院
				if (temp == data.rows[i].section_type) {
					 //console.log("if----temp:"+temp+"------data.rows[i].section_type:"+data.rows[i].section_type);
				     end++;
				} else {
				    if (end> start) {
					   //console.log("end > start----------start:"+start+"------end:"+end);
						for(var j = 0; j < mer.length; j ++){
							$('#arrange-tab').datagrid('mergeCells', {
								index: start,//起始索引
								rowspan: end - start + 1,  //需要合并的行数
								field: mer[j]
							});
						}
				   }
				    temp = data.rows[i].section_type;
				    start = i;
				    end = i;
				    //console.log("else----temp:"+temp+"------data.rows[i].section_type:"+data.rows[i].section_type
				    						// +"------start:"+start+"------end:"+end);
			 }
		 }
		    //这里是为了判断重复内容出现在最后的情况
		    if (end > start) {
				for(var j = 0; j < mer.length; j ++){
					$('#arrange-tab').datagrid('mergeCells', {
						index: start,
						rowspan: end - start + 1,
						field: mer[j]
					});
				}
		    }
		}/* 最大if结束 */
		
}



</script>
<div id="cc" class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north'" style="height:100px;">
       <img alt="" src="static/imgs/111.gif" width="85px" height="85px "  style="margin-left:45px;margin-top: 5px" ><span id="bt">HIS医疗系统</span>      
       <!-- <div class="yonghu">
       	<a style="margin-top: 33px;width: 50px; height: 27px;border-radius: 0px;" id="tuichu"  class="easyui-linkbutton" >退出</a> 
       			
	          
       </div> -->
       <div style="float:right;width:180px;height:95px;line-height: 91px;font-size: 20px;margin-right: 27px;">
       	欢迎登陆:	${user.userName}  
       </div>
    </div>
    <!--西 -->
    <div data-options="region:'west',title:'功能导航',split:true" style="width:200px;">
		<div id="aa" class="easyui-accordion" data-options="fit:true">
		<c:forEach items="${fts}" var="f1">
			   <h:fun funId="${f1.functionId}">
				    <div title="${f1.functionName}" data-options="iconCls:'${f1.functionIcon}'" style="overflow:auto;">
					    	<c:forEach items="${funs[f1.functionName]}" var="f2">
				    			<h:fun funId="${f2.functionId}">
					    		<a class="fun easyui-linkbutton" data-id="${f2.functionId}" data-href="${f2.functionUrl}" style="width:190px">${f2.functionName}</a>
					   			</h:fun>
					   		</c:forEach>
				    </div>
			    </h:fun> 
		</c:forEach>    
		</div>
    </div>
 	<!--中间 -->
      <div data-options="region:'center'"> 
		<div id="tt" class="easyui-tabs" data-options="fit:true,tools:'#tab-tools'">
		    <div title="工作台">
					<div id='calendar' style="position: relative;">  
						<div class="topbox" style="/* border:1px solid red; */width:1023px;height:53px;">
								<button  id="beforeday">前一天</button>
								<button  id="afterday">后一天</button>
								<a  id="datetext" style="margin-left: 300px;"></a>
								<!-- 存储当天的排班时间 -->
								<input  id="arrangetoday"  type="hidden"/>
								<!-- 存储角色名称 -->
								<input  id="arrange_role" class="ss" type="hidden"  value="医生"/>
								<!-- 原来班次--用于修改 -->
								<input  id="arrange_classID" class="arr" type="hidden"  value=""/>
								<!--原来排班日期--用于修改 -->
								<input  id="arrange_classTime" class="arr" type="hidden"  value=""/>
								<button  id="todaydate" style="margin-left:439px;">今天</button>
								<!-- <button  id="kindly-reminder" style="">新增班次</button> -->
						</div><!-- topbox -->
						<div style="width:1032px;height:438px;/*  border:1px solid red; */margin-left:46px;">
								<div id="arrange-tab-header" style="width:1028px;height:80px;border:1px solid #D4D4D4;border-width:1px  1px 0px 1px;
								        background-color:#fdfdfd;color: #333; position: absolute;top: 48px; z-index: 10;">
								     <div style="text-align:center;display:inline-block;line-height:72px;font-size: 12px;border-right:1px solid #ccc;
								      border-width: 0 1px 0 0;border-style: dotted;width:82px;height:79px;float: left;">部门</div>
								      
									  <div style="text-align:center;display:inline-block;line-height:72px;font-size: 12px;border-right:1px solid #ccc;
									  width:121.5px;height:79px;border-width: 0 1px 0 0;border-style: dotted;float: left;">科室</div>
									   
									   <div style="text-align:center;display:inline-block;font-size: 12px;border-right:1px solid #ccc;
									   width:273px;height:79px;border-width: 0 1px 0 0;border-style: dotted;float: left;">
									             <div style="display:inline-block;width:272px;height:25px;text-align:center;line-height:25px;border:1px solid #ccc;border-width: 0 0px 1px 0;border-style: dotted;">
									                      早
									             </div>
									            <div style="width:136.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 1px 1px 0;border-style: dotted;">
									                      医生
									             </div>
									             <div style="width:135.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 0 1px 0;border-style: dotted;">
									                      护士
									             </div> 
									               <a style="display:none" class="doc_morningid"> </a>
									              <div class="doc_morning" style="width:136.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 1px 0px 0;border-style: dotted;">
									                 
									             </div>
									             <a style="display:none" class="nurse_morningid"  id="nurse_morning_id"> </a>
									             <div class="nurse_morning" style="width:135.5px;height:25px;text-align:center;float: left;line-height:25px;border:1px solid #ccc;border-width: 0 0 0px 0;border-style: dotted;">
									                 
									             </div>       
									  </div>
									   <div style="text-align:center;display:inline-block;font-size: 12px;border-right:1px solid #ccc;
									   width:273px;height:79px;border-width: 0 1px 0 0;border-style: dotted;float: left;">
									             <div style="display:inline-block;width:272px;height:25px;text-align:center;line-height:25px;border:1px solid #ccc;border-width: 0 0px 1px 0;border-style: dotted;">
									                      中
									             </div>
									            <div style="width:136.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 1px 1px 0;border-style: dotted;">
									                      医生
									             </div>
									             <div style="width:135.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 0 1px 0;border-style: dotted;">
									                      护士
									             </div> 
									               <a style="display:none" class="doc_eveningid"> </a>
									              <div class="doc_evening" style="width:136.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 1px 0px 0;border-style: dotted;">
									                   
									             </div>
									             <a style="display:none" class="nurse_eveningid"> </a>
									             <div class="nurse_evening" style="width:135.5px;height:25px;text-align:center;float: left;line-height:25px;border:1px solid #ccc;border-width: 0 0 0px 0;border-style: dotted;">
									                     
									             </div>       
									  </div>
								    <div style="text-align:center;display:inline-block;font-size: 12px;border-right:1px solid #ccc;
									   width:273px;height:79px;border-width: 0 1px 0 0;border-style: dotted;float: left;">
									             <div style="display:inline-block;width:272px;height:25px;text-align:center;line-height:25px;border:1px solid #ccc;border-width: 0 0px 1px 0;border-style: dotted;">
									                      晚
									             </div>
									            <div style="width:136.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 1px 1px 0;border-style: dotted;">
									                      医生
									             </div>
									             <div style="width:135.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 0 1px 0;border-style: dotted;">
									                      护士
									             </div> 
									              <a style="display:none" class="doc_nightid"> </a>
									              <div class="doc_night" style="width:136.5px;height:26px;text-align:center;float: left;line-height:26px;border:1px solid #ccc;border-width: 0 1px 0px 0;border-style: dotted;">
									                    
									             </div>
									               <a style="display:none" class="nurse_nightid"> </a>
									             <div class="nurse_night" style="width:135.5px;height:25px;text-align:center;float: left;line-height:25px;border:1px solid #ccc;border-width: 0 0 0px 0;border-style: dotted;">
									                  
									             </div>       
									  </div>
								</div>
						
						  		<table  id="arrange-tab" class="datagrid-header easyui-datagrid" data-options="fitColumns:false,singleSelect:true,onLoadSuccess:Mergerows" style="width:1030px;height:435px">
						
						 	  </table>
						</div><!--排班表格 -->	
			      </div><!-- calendar -->
		   </div><!-- 	工作台 -->
		    
		</div>
    </div> 
   <!-- 工具栏 -->
	<div id="tab-tools" style="border-left:none;border-right:none;border-top:none">
		<div style="display: inline-block;height: 22px;float: left;margin-right: 10px;">
			<a id="tuichu"  style="cursor:pointer;text-decoration:none;font-size:14px;
			margin-top:3px;color: red;float: left;display: inline-block;">退出登录</a> 
		</div>   	
 		
 		<a id="tab-remove" href="#" class="easyui-linkbutton" plain="true" iconCls="icon-remove"></a>
		<a id="tab-clear" href="#" class="easyui-linkbutton" plain="true" iconCls="icon-cancel"></a>
  </div>
   
</div>

<!-- 新增 -->
<div id="order_class-addtabs-win" class="easyui-window" title="排班" style="width:785px;height:430px;"
data-options="iconCls:'icon-save',modal:true,shadow:true,closed:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
<div id="look-patient-tab" style="width:771px;height: 398x;/* border: 1px solid #bbb; */">
      <!--  左边盒子 -->
       <div style="width:222px;height:382px;border:1px solid #529fc6;float:left;margin-top:5px;margin-left: 5px;">
             <a style="width:220px;height:42px;border:1px solid #529fc6;font-size:17px; display: inline-block;
              line-height: 42px;text-align: center;background: #529fc6;color: white;">排班基本信息</a>
            <div style=" padding-left:13px;width:205px;margin-top: 5px;">
              <div style="margin-top:22px;">  
                 <span style="margin-right:6px;">排班日期</span>
	    	<a>
	    		<input id="orderclass_time"  name="orderclass_time" class="easyui-datebox" value="" data-options="width:135,height:29,events:{blur:selecttime}">
	    	</a>
              </div>  
              <div style="margin-top:26px;">
                 <span style="margin-right:6px;">排班科室</span>
    	    <a>
    		  <select  id="sections" name="sectionname"  class="easyui-combobox" 
    		    data-options="width:135,height:29">
			 </select>
    	   </a>
               </div>
               
               <div style="margin-top:26px;">
			  <span style="margin-right:6px;">排班人员</span>
		      <a>
	    		  <select  id="section-people" name="user_id"  class="easyui-combobox"  data-options="width:135,height:29,required:true">
				 </select>
		     </a>
		</div>
		
		  <div style="margin-top:26px;">
                   <span style="margin-right:6px;">开始班次</span>
		    	    <a>
		    	     <select  id="orderclass_startime" name="orderclass_startime"  class="arrangeClassid easyui-combobox"  data-options="width:135,height:29, panelHeight:'auto'">
					   <%-- <c:forEach items="${selectarrange_time}"  var="s">
						        <option>${fn:substring(s.arrange_starclassses,0,5)}—${fn:substring(s.arrange_endclassses,0,5)}</option>
						        </c:forEach> 
					  --%>
					 </select>
		        	</a>
               </div>
                <div style="margin-top:26px;">
                   <span style="margin-right:6px;">结束班次</span>
		    	    <a>
		    	     <select  id="orderclass_endtime" name="orderclass_endtime"  class="arrangeClassid_end easyui-combobox"  data-options="width:135,height:29, panelHeight:'auto'">
				
					 </select>
		        	</a>
               </div>
               <div style="margin-top:26px;">
               	<a style="margin-left:66px;" id="arrange-submit-field" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">提交至排班</a> 
		    	<a style="margin-left:73px;" id="arrangeUpdate-submit" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">修改</a> 
               </div>
            </div>
       </div>
       <!--  右边盒子 -->
        <div style="width:528px;height:382px;border:1px solid #529fc6;float:left;margin-left:5px;margin-top:5px;">
                  <a style="width:526px;height:42px;border:1px solid #529fc6;font-size:17px; display: inline-block;
                     line-height: 42px;text-align: center;background: #529fc6;color: white;">排班</a>
                     <!-- 新增表格 -->
                 <!--     <div id="arrange-fieldtab-header" style="width:99.56%;height:30px;border:1px solid #D4D4D4;border-width:1px  1px 0px 1px;background-color:#fdfdfd;color: #333;">
			    	      <div style="text-align:center;display:inline-block;line-height:27px;font-size: 12px;border-right:1px solid #ccc;
			    	       border-width: 0 1px 0 0;border-style: dotted;width:99px;height:30px;float: left;">科室名称</div>
					       
					       <div style="text-align:center;display:inline-block;line-height:27px;font-size: 12px;border-right:1px solid #ccc;
			    	       border-width: 0 1px 0 0;border-style: dotted;width:99px;height:30px;float: left;">用户名称</div>
			    	       
			    	       <div style="text-align:center;display:inline-block;line-height:27px;font-size: 12px;border-right:1px solid #ccc;
			    	       border-width: 0 1px 0 0;border-style: dotted;width:99px;height:30px;float: left;">开始班次</div>
			    	      
			    	       <div style="text-align:center;display:inline-block;line-height:27px;font-size: 12px;border-right:1px solid #ccc;
			    	       border-width: 0 1px 0 0;border-style: dotted;width:99px;height:30px;float: left;">结束班次</div>
			    	       
			    	       <div style="text-align:center;display:inline-block;line-height:27px;font-size: 12px;
			    	        width:125px;height:30px;float: left;">排班日期</div>
 					</div>	 -->       
	      			<table id="order_class-addtabs" class="easyui-datagrid"style="width:100%; height:285px"data-options="fitColumns:false,singleSelect:false">
						
					 </table>
					 <a style="margin-top:2px;margin-top:14px;margin-left:88%;" 
					 id="arrange-submit" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">确定</a> 
          </div>
 </div>
</div>

<!-- 弹框提示 -->
<div id="saveclinic-win" class="easyui-window"  title="提示框" style="width:300px;height:156px"
    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
          <p class="window-tishi" style=" margin-left:45px;font-size: 16px;margin-top: 47px;">
          </p>
</div>

<!-- 修改班次 ,-->
<div id="kindly-reminder-win" class="easyui-window"  title="班次修改" style="width:400px;height:256px"
    data-options="iconCls:'icon-save',modal:true,resizable:false,closed:true,collapsible:false,maximizable:false,minimizable:false">
    <div style="margin-top:7px;margin-left:7px;">
     <span style="margin-right:7px;">季节班次</span>
	  <select class="arrange_type easyui-combobox"  data-options="panelHeight:'auto' " style="width:100px;height:28px;">
			   <option value="夏季班次">夏季班次</option>
			   <option value="冬季班次">冬季班次</option>
	  </select>
	</div>
	<div style="margin-top:7px;margin-left:7px;">
        <span style="margin-right:7px;"></span>
	 
	</div>
</div>

</body>
</html>
